{% extends "admin/bases.html" %}
 {% import "admin/fy.html" as pg %}

{% block content %}

    
    <div class="x-body">
           <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so" method="post">
           {{form.goods_name}}
            {{form.csrf_token}}
          {{form.submit}}
        </form>
      </div>

      <xblock>

        <button class="layui-btn" onclick="x_admin_show('添加商品名','{{url_for("admin.addTradeName")}}')">添加商品种类名</button>
      </xblock>
      <table class="layui-table">
        <thead>

          <tr>

            <th>商品名称</th>
            <th>价格</th>
            <th>介绍</th>
            <th >操作</th>
            </tr>
        </thead>
        <tbody>
            {% for i in page_data.items %}
          <tr>

            <td>{{i.goods_name}}</td>
            <td>{{i.goods_price}}</td>
            <td>{{i.goods_intro}}</td>
            <td class="td-manage">
              <a title="删除" onclick="member_del(this,'{{i.goods_id}}')" href="javascript:;">
                <i class="layui-icon">&#xe640;</i>
              </a>
            </td>
          </tr>
        {% endfor %}
        </tbody>
      </table>
        {{pg.page(page_data,'admin.categoryOfGoods')}}

    </div>
    <script>
      layui.use('laydate', function(){
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
          elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
          elem: '#end' //指定元素
        });
      });



       function member_del(obj, id) {
              console.log(id)
              layer.confirm('确认要删除吗？', function (index) {
                  //发异步删除数据
                  $.get(
                      'http://127.0.0.1:5050/admin/dellgoods?id=' + id,

                      function (html) {
                           parent.location.reload();
                      }
                  );
                  $(obj).parents("tr").remove();
                  layer.msg('已删除!', {icon: 1, time: 1000});
              });
          }
    </script>

{% endblock %}